import _ from 'lodash'
import { getSize } from './utils' 
import Router from '../router/router'
import '../asset/css/style.scss'
let timer = null
getSize()
window.onresize = function () {
  clearTimeout(timer)
  timer = setTimeout(() => {
    getSize()
  }, 1000)
}
// 注册组件
document.getElementById('app').innerHTML = Router.get(window.location.hash.slice(1) || 'introduce')
window.onhashchange = function () {
  const hasher = window.location.hash.slice(1)
  document.getElementById('app').innerHTML = ''
  const searcher = Router.has(hasher) ? Router.get(hasher) : Router.get(404)
  document.getElementById('app').innerHTML = searcher
}
// 插入 html 导航模板
let html = ''
for (let item of Router.keys()) {
  if (item === 404) continue
  html = `${html}<li>
      <a href=#${item}>${item}</a>
    </li>`
}
document.getElementById('list').innerHTML = html

// var c = 1
// console.log(c) // 1
// function c() {}
// console.log(c) // 1